/**
 * 
 */
package de.cbf.cam.dsa.model.prerequisites;

import javax.persistence.Entity;

import de.cbf.cam.dsa.model.entities.BattleChar;
import de.cbf.cam.dsa.model.entities.OneNPC;
import de.cbf.cam.dsa.model.entities.OneTalent;

/**
 * @author Nebelritter
 *
 */
@Entity
public class TalentPrereq extends Prereq {

	/**
	 * @uml.property  name="talentName"
	 */
	private String 	talentName 	= "";
	/**
	 * @uml.property  name="value"
	 */
	private int 	value 		= 0;
	
	public TalentPrereq(String talentName, int value) {
		super();
		this.talentName = talentName;
		this.value = value;
	}

	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.model.prerequisites.Prereq#characterMeetsPrereq(de.cbf.cam.dsa.model.entities.OneNPC)
	 */
	@Override
	public boolean characterMeetsPrereq(OneNPC character) {
		OneTalent talent = character.getTalent(talentName);
		if(talent != null){
			if(talent.getTalValue()>=value){
				return true;
			}
		}
		return false;
	}

	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.model.prerequisites.Prereq#characterMeetsPrereq(de.cbf.cam.dsa.model.entities.BattleChar)
	 */
	@Override
	public boolean characterMeetsPrereq(BattleChar character) {
		return characterMeetsPrereq(character.getCharacter());
	}

}
